package org.runecore.rs2.model.player;

import java.io.Serializable;

import org.runecore.rs2.model.Entity;
import org.runecore.rs2.model.World;
import org.runecore.rs2.net.PacketBuilder;

/**
 * RuneCore
 * Sep 4, 2011
 * @author Harry Andreas<Harry@RuneCore.org>
 */

public class Player extends Entity implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -2094670733429848054L;

	/**
	 * Details of the <code>Player</code>
	 */
	private String username, password;
	
	/**
	 * The <code>GameSession</code> for the player instance
	 */
	private transient GameSession session;
	
	/**
	 * Constructor
	 */
	public Player(String user, String pass, GameSession session) {
		super();
		setUsername(user);
		setPassword(pass);
		this.setSession(session);
	}
	
	/**
	 * Sends Skills
	 */
	public void sendSkills() {
		for(int i = 0; i < 21; i++) {
			PacketBuilder.sendSkill(getSession(), i, 10, 1154);
		}
	}

	/**
	 * @param username the username to set
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * @param password the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @return the session
	 */
	public GameSession getSession() {
		return session;
	}

	/**
	 * Executes a <code>Player</code> update event
	 */
	@Override
	public void update() {
		World.getSingleton().getSelectedRevision().getUpdateHandler().handleUpdate(getSession());
	}

	@Override
	public void tick() {
		// Nothing here to do :P
	}

	/**
	 * @param session the session to set
	 */
	public void setSession(GameSession session) {
		this.session = session;
	}

}